#/bin/python
#coding:utf8
'''
Created on 2011-4-29

@author: mark
'''


VERSION = 0.1

import os
import web
import memcache
from web.contrib.template import render_jinja 


database = web.database(dbn="mysql", db="hc", host="127.0.0.1", port=3306, user="root", passwd="123456")

app_path = os.path.abspath(os.path.curdir)
session_path = os.path.join(os.path.abspath(os.path.pardir), 'session')

template_path = os.path.join(app_path, 'static', 'view')
template_problem_path = os.path.join(template_path, "problem")
template_user_path = os.path.join(template_path, 'user')
template_test_path = os.path.join(template_path, 'test')
template_index_path = os.path.join(template_path, 'index')

upload_path = os.path.join(app_path, 'static', 'upload')
problem_path = os.path.join(upload_path,'problem')
userlogo_path = os.path.join(upload_path,'logo')
captcha_path = os.path.join(app_path,'static','img','captcha')

problem_image_path = "/static/upload/problem/"
user_logo_path = "/static/upload/logo/"

defaut_logo = "/static/img/default.jpg"

memcache_client = memcache.Client(['127.0.0.1:12000'], debug=0)
cache_timeout = 60 * 60 * 24

template = render_jinja(
        template_path, # Set template directory.
        encoding='utf-8', # Encoding.
    )

template_problem = render_jinja(
        template_problem_path, # Set template directory.
        encoding='utf-8', # Encoding.
    )

template_user = render_jinja(
        template_user_path, # Set template directory.
        encoding='utf-8', # Encoding.
    )

template_test = render_jinja(
        template_test_path, # Set template directory.
        encoding='utf-8', # Encoding.
    )

template_index = render_jinja(
        template_index_path, # Set template directory.
        encoding='utf-8', # Encoding.
    )

#cookie setting
cookie_expire = 3600 * 24 * 7

#pages

pagesize = 20
pagecountCacheTimeout = 60 * 5

#font
fontpath = os.path.join(app_path, 'static', 'font', 'ARIAL.TTF')

#func_cache
month_func_cache =5*24*60*60
week_func_cache = 24*60*60